package com.ruoyi.framework.sms;

import cn.hutool.json.JSONUtil;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.ruoyi.common.entity.ValidateData;

import java.util.HashMap;
import java.util.Map;

/**
 * 短信发送模板
 *
 * @author dyun
 */
public class ValidateCodeTemplate {

    /**
     * 待发送手机号
     */
    private final String phoneNumbers;


    public ValidateCodeTemplate(String phoneNumbers) {
        this.phoneNumbers = phoneNumbers;
    }

    public SendSmsRequest getSmsRequest(ValidateData validateData) {
        SendSmsRequest request = new SendSmsRequest();
        request.setPhoneNumbers(this.phoneNumbers);

        Map<String, Object> map = new HashMap<>(16);
        map.put("code", validateData.getCode());
        request.setTemplateParam(JSONUtil.toJsonStr(map));
        return request;
    }
}
